#!/bin/sh

chroot_path=@CHROOT_PATH@

get_pa_sock_path()
{
	PA_SOCK_PATH=$(sockstat | awk -v me=$(whoami) -F'[ \t]+' '
		$1 == me && $2 == "pulseaudio" && $6 ~ /native/ {
			print $6;
			exit 0
		}'
	)
}

get_pa_sock_path
if [ ! -S "$PA_SOCK_PATH" ]; then
	while killall pulseaudio; do
		sleep 0.5
	done
	pulseaudio --start
	get_pa_sock_path
fi
[ -S "$PA_SOCK_PATH" ] && export PULSE_SERVER=unix:$PA_SOCK_PATH
${chroot_path}/bin/@BROWSER@

